## Counter
## 等等，可以优化，顺序无所谓?
## 那么每一轮开始前逆序排列，则检查是否进行的？没必要
from collections import Counter


n1,n2=[int(i) for i in input().split()]
lnum=[i for i in range(n1,n2+1)] #10得包括
width=len(lnum)
def check(alist): #大于10
    for i in alist:
        if i>=10:
            return True
    return False

def mul(numlist):
    pro=1
    for num in numlist:
        pro*=num

    return sum([int(x) for x in str(pro)])
    


while check(lnum):
    for i in range(width):
        if lnum[i]<2:
            continue
        cubes=[int(j)**3 for j in str(lnum[i])] ##list
        lnum[i]=mul(cubes)

cnt=Counter(lnum)
res=cnt.most_common()

ans=[]
# ans=[i for i in res if i[1]==first]
for i in range(len(res)):
    if res[i][1]<res[i-1][1]:
        break
    else:
        ans.append(res[i][0])

ans.sort()
print(res[0][1])
print(*ans)
